home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / misc / libx11inc.lha / X11 / Xm / TextOutP.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-13  |  13.8 KB  |  443 lines

  1. /* 
  2.  * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC.
  3.  * ALL RIGHTS RESERVED
  4. */ 
  5. /*   $RCSfile: TextOutP.h,v $ $Revision: 1.36 $ $Date: 92/05/14 12:59:25 $ */
  6. /*
  7. *  (c) Copyright 1989, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
  8. /*
  9. *  (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 HEWLETT-PACKARD COMPANY */
  10. #ifndef _XmTextOutP_h
  11. #define _XmTextOutP_h
  12.  
  13. #include <Xm/XmP.h>
  14. #include <Xm/Text.h>
  15.  
  16. #if defined(__cplusplus) || defined(c_plusplus)
  17. extern "C" {
  18. #endif
  19.  
  20. /****************************************************************
  21.  *
  22.  * Definitions for modules implementing and using text output routines.
  23.  *
  24.  ****************************************************************/
  25.  
  26. #define ShouldWordWrap(data, widget)    (data->wordwrap && \
  27.        (!(data->scrollhorizontal && \
  28.        (XtClass(widget->core.parent) == xmScrolledWindowWidgetClass))) \
  29.        && widget->text.edit_mode != XmSINGLE_LINE_EDIT && !data->resizewidth)
  30.  
  31. typedef struct _LineTableExtraRec {
  32.     Dimension width;
  33.     Boolean wrappedbychar;
  34. } LineTableExtraRec, *LineTableExtra ;
  35.  
  36. /*         
  37.  * output.c  (part of stext)
  38.  */
  39.  
  40. typedef unsigned int LineNum;
  41. typedef enum {on, off} OnOrOff;    /* For when Booleans aren't obvious enough. */
  42.  
  43. /*
  44.  * Return the line number containing the given position.  If text currently
  45.  * knows of no line containing that position, returns NOLINE.
  46.  */
  47.  
  48. #define NOLINE    30000
  49.  
  50. /*
  51.  * These next define the types of the routines that output is required
  52.  * to export for use by text and by input.
  53.  */
  54.  
  55. typedef struct _OutputDataRec {
  56.     XmFontList fontlist;    /* Fontlist for text. */
  57.     unsigned int blinkrate;
  58.     Boolean wordwrap;        /* Whether to wordwrap. */
  59.     Boolean cursor_position_visible;
  60.     Boolean autoshowinsertpoint;
  61.     Boolean hasfocus;
  62.     Boolean has_rect;
  63.     Boolean handlingexposures;    /* TRUE if in the midst of expose events. */
  64.     Boolean exposevscroll;    /* Non-zero if we expect expose events to be
  65.                    off vertically. */
  66.     Boolean exposehscroll;    /* Non-zero if we expect expose events to be
  67.                    off horizontally. */
  68.     Boolean resizewidth, resizeheight;
  69.     Boolean scrollvertical, scrollhorizontal;
  70.     Boolean scrollleftside, scrolltopside;
  71.     Boolean ignorevbar;        /* Whether to ignore callbacks from vbar. */
  72.     Boolean ignorehbar;        /* Whether to ignore callbacks from hbar. */
  73.     short int cursor_on;        /* Whether IBeam cursor is visible. */
  74.     Boolean refresh_ibeam_off;    /* Indicates whether area under IBeam needs
  75.                  * to be re-captured */
  76.     Boolean suspend_hoffset;    /* temporarily suspend horizontal scrolling */
  77.     Boolean use_fontset;        /* True if font to be used is fontset (and
  78.                  * thus need X11R5 Xmb* routines to draw */
  79.     Boolean have_inverted_image_gc; /* fg/bg of image gc have been swapped;
  80.                      * on == True, off == False */
  81.     OnOrOff blinkstate;
  82.     Position insertx, inserty;
  83.     int number_lines;        /* Number of lines that fit in the window. */
  84.     int leftmargin, rightmargin;
  85.     int topmargin, bottommargin;
  86.     int scrollwidth;        /* Total width of text we have to display. */
  87.     int vsliderSize;        /* How big the thumb is in the vbar. */
  88.     int hoffset;        /* How much we've scrolled off the left. */
  89.     int averagecharwidth;    /* Number of pixels for an "average" char. */
  90.     int tabwidth;        /* Number of pixels for a tab. */
  91.     short columns, rows;
  92.     Dimension lineheight;    /* Number of pixels per line. */
  93.     Dimension minwidth, minheight;
  94.     Dimension prevW;
  95.     Dimension prevH;
  96.     Dimension cursorwidth, cursorheight;
  97.     Dimension font_ascent;      /* ascent of the font[set] */
  98.     Dimension font_descent;     /* descent of the font[set] */
  99.     XtIntervalId timerid;
  100.     Pixmap cursor;        /* Pixmap for IBeam cursor stencil. */
  101.     Pixmap add_mode_cursor;    /* Pixmap to use for add mode cursor. */
  102.     Pixmap ibeam_off;        /* Pixmap for area under the IBeam. */
  103.     Pixmap stipple_tile;    /* stiiple for add mode cursor. */
  104.     GC gc, imagegc;
  105.     Widget vbar, hbar;
  106.     XFontStruct *font;        /* font used when NULL font is set. */
  107. /* New for 1.2 */
  108.     GC save_gc;                 /* GC for saving/resotring under IBeam */
  109.     short columns_set, rows_set; /* history of previously set dimensions */
  110. } OutputDataRec, *OutputData;
  111.  
  112.  
  113. /*
  114.  * Create a new instance of an output object.  This is expected to fill in
  115.  * info about innerwidget and output in the widget record.
  116.  */
  117.  
  118. #ifdef _NO_PROTO
  119. typedef void (*OutputCreateProc)();
  120. #else
  121. typedef void (*OutputCreateProc)(
  122.             Widget,
  123.             ArgList,
  124.             Cardinal) ;
  125. #endif
  126. /*
  127.  * Given an (x,y) coordinate, return the closest corresponding position. (For
  128.  * use by input; text shouldn't ever need to know.)
  129.  */
  130.  
  131. #ifdef _NO_PROTO
  132. typedef XmTextPosition (*XYToPosProc)(); /* ctx, x, y */
  133. #else
  134. typedef XmTextPosition (*XYToPosProc)(
  135.             XmTextWidget,
  136. #if NeedWidePrototypes
  137.             int,
  138.             int) ;
  139. #else
  140.             Position,    /* These are relative to the */
  141.             Position) ;    /* innerwindow returned above. */
  142. #endif
  143. #endif
  144.  
  145. /*
  146.  * Return the (x,y) coordinate corresponing to the given position.  If this
  147.  * returns FALSE, then the given position isn't being displayed.
  148.  */
  149.  
  150. #ifdef _NO_PROTO
  151. typedef Boolean (*PosToXYProc)(); /* widget, position, x, y */
  152. #else
  153. typedef Boolean (*PosToXYProc)(
  154.             XmTextWidget,
  155.             XmTextPosition,
  156.             Position *,    /* These are relative to the */
  157.             Position *) ;    /* innerwindow returned above. */
  158. #endif
  159.  
  160. /*
  161.  * Measures the extent of a line.  Given the line number and starting position
  162.  * of a line, returns the starting position of the next line.  Also returns
  163.  * any extra information that the output module may want to associate with
  164.  * this line for future reference.  (In particular, it will want to associate
  165.  * a vertical coordinate for this line.)  This routine should return FALSE if
  166.  * it decides that this line will not fit in the window.  FALSE should never
  167.  * be returned if the line number is zero.  Output may assume that the line
  168.  * table for all preceeding lines have already been set.  In particular, when
  169.  * this routine will return FALSE, then output knows that the entire linetable
  170.  * has been calculated; that is a good time for it to look over the linetable
  171.  * and decide if it wants to do something obnoxious like resize the window.
  172.  *
  173.  * A possible value to put in nextpos is PASTENDPOS.  This indicates that the
  174.  * current line contains the end of the text in the source.
  175.  *
  176.  * nextpos may be NULL.  If it is, then this indicates that we only want to
  177.  * know if the line will fit on the window.  The caller already has its own
  178.  * idea where the next line will start if it does fit.  (If nextpos is NULL,
  179.  * then no extra information should be generated, and the 'extra' parameter
  180.  * should be ignored.)
  181.  */
  182.  
  183. #define PASTENDPOS    2147483647  /* Biggest number that can fit in long */
  184.  
  185. #ifdef _NO_PROTO
  186. typedef Boolean (*MeasureLineProc)(); /* ctx, line, pos, nextpos, extra */
  187. #else
  188. typedef Boolean (*MeasureLineProc)(
  189.             XmTextWidget,
  190.             LineNum,
  191.             XmTextPosition,
  192.             XmTextPosition *,
  193.             LineTableExtraRec **) ;
  194. #endif
  195.  
  196. /*
  197.  * Draw some text within a line.  The output finds out information about the
  198.  * line by calling the line table routines.
  199.  *
  200.  * %%% Document special cases (like lines containing PASTENDPOS).
  201.  */
  202.  
  203. #ifdef _NO_PROTO
  204. typedef void (*DrawProc)();    /* ctx, line, start, end, highlight */
  205. #else
  206. typedef void (*DrawProc)(
  207.             XmTextWidget,
  208.             LineNum,
  209.             XmTextPosition,
  210.             XmTextPosition,
  211.             XmHighlightMode) ;
  212. #endif
  213.  
  214. /*
  215.  * Output should draw or erase an insertion point at the given position.
  216.  */
  217.  
  218. #ifdef _NO_PROTO
  219. typedef void (*DrawInsertionPointProc)(); /* ctx, position, onoroff */
  220. #else
  221. typedef void (*DrawInsertionPointProc)(
  222.             XmTextWidget,
  223.             XmTextPosition,
  224.             OnOrOff) ;
  225. #endif
  226.  
  227. /*
  228.  * Output should ensure that the given position is visible (e.g., not scrolled
  229.  * off horizontally).
  230.  */
  231. #ifdef _NO_PROTO
  232. typedef void (*MakePositionVisibleProc)();    /* widget, position */
  233. #else
  234. typedef void (*MakePositionVisibleProc)(
  235.             XmTextWidget,
  236.             XmTextPosition) ;
  237. #endif
  238.  
  239. /* Text would like to move some lines around on the screen.  It would like to
  240.  * move lines fromline through toline (inclusive) to now start at line
  241.  * destline.  If output can perform this move by means of a XCopyArea or
  242.  * similar simple call, it does so and returns TRUE; otherwise, it will return
  243.  * FALSE.  If TRUE, output should modify affected values in the
  244.  * "extra" entries in the linetable, because after returning text will go ahead
  245.  * and move linetable entries around.
  246.  */
  247.  
  248. #ifdef _NO_PROTO
  249. typedef Boolean (*MoveLinesProc)(); /* ctx, fromline, toline, destline */
  250. #else
  251. typedef Boolean (*MoveLinesProc)(
  252.             XmTextWidget,
  253.             LineNum,
  254.             LineNum,
  255.             LineNum) ;
  256. #endif
  257.  
  258. /*
  259.  * Inform output of invalidated positions.
  260.  */
  261.  
  262. #ifdef _NO_PROTO
  263. typedef void (*InvalidateProc)(); /* ctx, position, topos, delta */
  264. #else
  265. typedef void (*InvalidateProc)(
  266.             XmTextWidget,
  267.             XmTextPosition,
  268.             XmTextPosition,
  269.             long) ;
  270. #endif
  271.  
  272. /*
  273.  * Get preferred size of text widget based on the row and column
  274.  * resources multiplied by font attributes as well as adding the
  275.  * margin resource values to the computed size.
  276.  */
  277. #ifdef _NO_PROTO
  278. typedef void (*GetPreferredSizeProc)(); /* widget, width, height */
  279. #else
  280. typedef void (*GetPreferredSizeProc)(
  281.             Widget,
  282.             Dimension *,
  283.             Dimension *) ;
  284. #endif
  285.  
  286. /*
  287.  * Get values out of the output object.
  288.  */
  289.  
  290. #ifdef _NO_PROTO
  291. typedef void (*GetValuesProc)(); /* widget, args, num_args */
  292. #else
  293. typedef void (*GetValuesProc)(
  294.             Widget,
  295.             ArgList,
  296.             Cardinal) ;
  297. #endif
  298.  
  299. /*
  300.  * Set values in the output object.
  301.  */
  302.  
  303. #ifdef _NO_PROTO
  304. typedef Boolean (*SetValuesProc)(); /* oldw, reqw, new_w, args, num_args */
  305. #else
  306. typedef Boolean (*SetValuesProc)(
  307.             Widget,
  308.             Widget,
  309.             Widget,
  310.             ArgList,
  311.             Cardinal *) ;
  312. #endif
  313.  
  314.  
  315. typedef struct _OutputRec {
  316.     struct _OutputDataRec    *data; /* Output-specific data; opaque type. */
  317.     XYToPosProc            XYToPos;
  318.     PosToXYProc            PosToXY;
  319.     MeasureLineProc        MeasureLine;
  320.     DrawProc            Draw;
  321.     DrawInsertionPointProc    DrawInsertionPoint;
  322.     MakePositionVisibleProc    MakePositionVisible;
  323.     MoveLinesProc        MoveLines;
  324.     InvalidateProc        Invalidate;
  325.     GetPreferredSizeProc    GetPreferredSize;
  326.     GetValuesProc        GetValues;
  327.     SetValuesProc        SetValues;
  328.     XmRealizeOutProc        realize;
  329.     XtWidgetProc        destroy;
  330.     XmResizeFlagProc        resize;
  331.     XtExposeProc        expose;
  332. } OutputRec;
  333.  
  334.  
  335. /********    Private Function Declarations    ********/
  336. #ifdef _NO_PROTO
  337.  
  338. extern void _XmTextFreeContextData() ;
  339. extern void _XmTextResetClipOrigin() ;
  340. extern void _XmTextAdjustGC() ;
  341. extern Boolean _XmTextShouldWordWrap() ;
  342. extern Boolean _XmTextScrollable() ;
  343. extern XmTextPosition _XmTextFindLineEnd() ;
  344. extern void _XmTextOutputGetSecResData() ;
  345. extern int _XmTextGetNumberLines() ;
  346. extern void _XmTextMovingCursorPosition() ;
  347. extern void _XmTextDrawDestination() ;
  348. extern void _XmTextClearDestination() ;
  349. extern void _XmTextDestinationVisible() ;
  350. extern void _XmTextChangeBlinkBehavior() ;
  351. extern void _XmTextOutputCreate() ;
  352. extern Boolean _XmTextGetBaselines() ;
  353. extern Boolean _XmTextGetDisplayRect() ;
  354. extern void _XmTextMarginsProc() ;
  355. extern void _XmTextChangeHOffset() ;
  356. extern void _XmTextToggleCursorGC() ;
  357.  
  358. #else
  359.  
  360. extern void _XmTextFreeContextData( 
  361.                         Widget w,
  362.                         XtPointer clientData,
  363.                         XtPointer callData) ;
  364. extern void _XmTextResetClipOrigin( 
  365.                         XmTextWidget tw,
  366.                         XmTextPosition position,
  367. #if NeedWidePrototypes
  368.                         int clip_mask_reset) ;
  369. #else
  370.                         Boolean clip_mask_reset) ;
  371. #endif /* NeedWidePrototypes */
  372. extern void _XmTextAdjustGC( 
  373.                         XmTextWidget tw) ;
  374. extern Boolean _XmTextShouldWordWrap( 
  375.                         XmTextWidget widget) ;
  376. extern Boolean _XmTextScrollable( 
  377.                         XmTextWidget widget) ;
  378. extern XmTextPosition _XmTextFindLineEnd( 
  379.                         XmTextWidget widget,
  380.                         XmTextPosition position,
  381.                         LineTableExtra *extra) ;
  382. extern void _XmTextOutputGetSecResData( 
  383.                         XmSecondaryResourceData *secResDataRtn) ;
  384. extern int _XmTextGetNumberLines( 
  385.                         XmTextWidget widget) ;
  386. extern void _XmTextMovingCursorPosition( 
  387.                         XmTextWidget tw,
  388.                         XmTextPosition position) ;
  389. extern void _XmTextDrawDestination( 
  390.                         XmTextWidget widget) ;
  391. extern void _XmTextClearDestination( 
  392.                         XmTextWidget widget,
  393. #if NeedWidePrototypes
  394.                         int ignore_sens) ;
  395. #else
  396.                         Boolean ignore_sens) ;
  397. #endif /* NeedWidePrototypes */
  398. extern void _XmTextDestinationVisible( 
  399.                         Widget w,
  400. #if NeedWidePrototypes
  401.                         int turn_on) ;
  402. #else
  403.                         Boolean turn_on) ;
  404. #endif /* NeedWidePrototypes */
  405. extern void _XmTextChangeBlinkBehavior( 
  406.                         XmTextWidget widget,
  407. #if NeedWidePrototypes
  408.                         int newvalue) ;
  409. #else
  410.                         Boolean newvalue) ;
  411. #endif /* NeedWidePrototypes */
  412. extern void _XmTextOutputCreate( 
  413.                         Widget wid,
  414.                         ArgList args,
  415.                         Cardinal num_args) ;
  416. extern Boolean _XmTextGetBaselines( 
  417.                         Widget widget,
  418.                         Dimension **baselines,
  419.                         int *line_count) ;
  420. extern Boolean _XmTextGetDisplayRect( 
  421.                         Widget w,
  422.                         XRectangle *display_rect) ;
  423. extern void _XmTextMarginsProc( 
  424.                         Widget w,
  425.                         XmBaselineMargins *margins_rec) ;
  426. extern void _XmTextChangeHOffset( 
  427.                         XmTextWidget widget,
  428.                         int length) ;
  429. extern void _XmTextToggleCursorGC( 
  430.                         Widget widget) ;
  431.  
  432. #endif /* _NO_PROTO */
  433. /********    End Private Function Declarations    ********/
  434.  
  435.  
  436.  
  437. #if defined(__cplusplus) || defined(c_plusplus)
  438. }  /* Close scope of 'extern "C"' declaration which encloses file. */
  439. #endif
  440.  
  441. #endif /* _XmTextOutP_h */
  442. /* DON'T ADD ANYTHING AFTER THIS #endif */
  443.